<?php
include_once('header.inc.php');
if(!isset($_POST['login'])){
   if(!isset($_GET['login'])){
      redirection('index.php?erreur=-1');
      exit();
   }
   $login = $_GET['login'];
   $pass = $_GET['pass'];
}
else{
   if(isset($_GET['login'])){
      if($_GET['login']!=$_POST['login'] || $_GET['pass']!=$_POST['pass']){
         redirection('index.php?erreur=-2');
         exit();
      }
   }
   $login = $_POST['login'];
   $pass = md5($_POST['pass']);
}
$t = $db->select('*',$CONFIG['table_users'],'login=\''.$login.'\' AND pass=\''.$pass.'\'');
$n = count($t);
if($n!=1){
   redirection('index.php?erreur='.$n);
   exit();
}
$_SESSION['login']=$login;
$_SESSION['pass']=$pass;
redirection('menu.php');
?>